#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include<stdlib.h>
typedef char BTDataType;
typedef struct TreeNode
{
    BTDataType _val;
    struct TreeNode* _left;
    struct TreeNode* _right;
}TreeNode;
TreeNode* CreatTree(BTDataType* array, int* pi)//建树
{
    if (array[*pi] == '#')
    {
        (*pi)++;
        return NULL;
    }
    else {
        TreeNode* root = (TreeNode*)malloc(sizeof(TreeNode));
        root->_val = array[*pi];
        (*pi)++;
        root->_left = CreatTree(array, pi);
        root->_right = CreatTree(array, pi);
        return root;
    }
}
//中序遍历
void InOrder(TreeNode* root)
{
    if (root == NULL)
    {
        return;
    }
    InOrder(root->_left);
    printf("%c ", root->_val);
    InOrder(root->_right);
}
int main() {
    BTDataType str[100];
    scanf("%s", str);
    int pi = 0;
    TreeNode* root = CreatTree(str, &pi);
    InOrder(root);
    return 0;
}